#ifndef STDIO_H
#define STDIO_H

static inline void out8(int port, uint8_t value)
{__asm__ __volatile__ ("outb %%al,%%dx" :: "a" (value), "d" (port));}

static inline void out16(int port, uint16_t value)
{__asm__ __volatile__ ("outw %%ax,%%dx" :: "a" (value), "d" (port));}

static inline void out32(int port, uint32_t value)
{__asm__ __volatile__ ("outl %%eax,%%dx" :: "a" (value), "d" (port));}

static inline uint8_t in8(int port)
{
    uint8_t value;
    __asm__ __volatile__ ("inb %%dx,%%al" : "=a" (value) : "d" (port));
    return value;
}

static inline uint16_t in16(int port)
{
    uint16_t value;
    __asm__ __volatile__ ("inw %%dx,%%ax" : "=a" (value) : "d" (port));
    return value;
}

static inline uint32_t in32(int port)
{
    uint32_t value;
    __asm__ __volatile__ ("inl %%dx,%%eax" : "=a" (value) : "d" (port));
    return value;
}

static inline void wrmsr(const size_t msr, const size_t data)
{
    asm volatile("wrmsr;"::"c"(msr), "d"(0), "a"(data));
}

static inline size_t rdmsr(const size_t msr)
{
    size_t eax;
    asm volatile("rdmsr;":"=a"(eax):"c"(msr));
    return eax;
}

#endif

